package com.xyht.sca_s.student_manage_system.modules.news.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.news.service.SmsNewsInformCollectService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 收藏表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-05-08
 */
@RestController
@RequestMapping("/userCollect")
@SecretBody
public class SmsNewsInformCollectController {

    @Autowired
    private SmsNewsInformCollectService smsNewsInformCollectService;
    @Autowired
    private JwtTokenUtil jwtTokenUtil;

    @ApiModelProperty("/查看收藏")
    @GetMapping("/list")
    public ResponseResult getCollectList(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                         @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                         HttpServletRequest request){
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return smsNewsInformCollectService.getCollectList(userId,pageSize,pageNum);
    }

}

